function add(){

		var intLine = parseInt(document.form1.hdnMaxLine.value);
		var maxLine = parseInt(document.form1.MaxLine.value);
		var lot = document.getElementById('LOT_NO'+intLine+'').value
		var count = document.getElementById('COUNT'+intLine+'').value
		var pbls = document.getElementById('PBLS'+intLine+'').value
		var lbs = document.getElementById('LBS'+intLine+'').value
		var shade = document.getElementById('SHADE'+intLine+'').value
		var wp = document.getElementById('WP'+intLine+'').value
		var rec = document.getElementById('REC'+intLine+'').value
		var org = document.getElementById('ORG'+intLine+'').value
		var cheese = document.getElementById('CHEESE'+intLine+'').value
		var fuai = document.getElementById('FUAI'+intLine+'').value
		intLine++;
		maxLine++;
		var theTable = document.getElementById("maininput");
		var newRow = theTable.insertRow(theTable.rows.length)
		newRow.id = newRow.uniqueID

		var item1 = 1
		var newCell
		
		newCell = newRow.insertCell(0)
		newCell.id = newCell.uniqueID
		newCell.setAttribute("className", "css-name");
		newCell.innerHTML = ""+intLine+""
		
		newCell = newRow.insertCell(1)
		newCell.id = newCell.uniqueID
		newCell.setAttribute("className", "css-name");
		newCell.innerHTML = "<INPUT TYPE=\"TEXT\" ID=\"COL_NO"+intLine+"\" CLASS=\"COL\" NAME=\"COL_NO\" VALUE=\"\">"

		newCell = newRow.insertCell(2)
		newCell.id = newCell.uniqueID
		newCell.setAttribute("className", "css-name");
		newCell.innerHTML = "&nbsp;-"

		newCell = newRow.insertCell(3)
		newCell.id = newCell.uniqueID
		newCell.setAttribute("className", "css-name");
		newCell.innerHTML = "<INPUT TYPE=\"TEXT\" ID=\"COL_SUB"+intLine+"\" CLASS=\"COL2\" NAME=\"COL_SUB\" VALUE=\"\"  onblur='addsub("+intLine+");'>"

		newCell = newRow.insertCell(4)
		newCell.id = newCell.uniqueID
		newCell.setAttribute("className", "css-name");
		newCell.innerHTML = "<INPUT TYPE=\"TEXT\" ID=\"LOT_NO"+intLine+"\" CLASS=\"COL3\" NAME=\"LOT_NO\" VALUE=\""+lot+"\">"		
		
		newCell = newRow.insertCell(5)
		newCell.id = newCell.uniqueID
		newCell.setAttribute("className", "css-name");
		newCell.innerHTML = "<INPUT TYPE=\"TEXT\" ID=\"COUNT"+intLine+"\" CLASS=\"COL3\" NAME=\"COUNT\" VALUE=\""+count+"\">"	
		
		newCell = newRow.insertCell(6)
		newCell.id = newCell.uniqueID
		newCell.setAttribute("className", "css-name");
		newCell.innerHTML = "<INPUT TYPE=\"TEXT\" ID=\"PBLS"+intLine+"\" CLASS=\"COL3\" NAME=\"PBLS\" VALUE=\""+pbls+"\">"			
	
		newCell = newRow.insertCell(7)
		newCell.id = newCell.uniqueID
		newCell.setAttribute("className", "css-name");
		newCell.innerHTML = "<INPUT TYPE=\"TEXT\" ID=\"LBS"+intLine+"\" CLASS=\"COL3\" NAME=\"LBS\" VALUE=\""+lbs+"\">"

		newCell = newRow.insertCell(8)
		newCell.id = newCell.uniqueID
		newCell.setAttribute("className", "css-name");
		newCell.innerHTML = "<SELECT ID=\"SHADE"+intLine+"\" NAME='SHADE' CLASS=\"list\"><OPTION value='P' >P</OPTION><OPTION value='M' >M</OPTION><OPTION value='D' >D</OPTION></SELECT>"
	
		newCell = newRow.insertCell(9)
		newCell.id = newCell.uniqueID
		newCell.setAttribute("className", "css-name");
		newCell.innerHTML = "<SELECT  ID=\"WP"+intLine+"\" NAME='WP' CLASS=\"list\"><OPTION VALUE=\"W\">W</OPTION><OPTION VALUE=\"P\">P</OPTION></SELECT>"
		
		newCell = newRow.insertCell(10)
		newCell.id = newCell.uniqueID
		newCell.setAttribute("className", "css-name");
		newCell.innerHTML = "<SELECT ID=\"REC"+intLine+"\" NAME='REC' CLASS=\"list\"><OPTION>BB</OPTION><OPTION>SBB</OPTION><OPTION>BC</OPTION><OPTION>SBC</OPTION><OPTION>SS</OPTION></SELECT>"

		newCell = newRow.insertCell(11)
		newCell.id = newCell.uniqueID
		newCell.setAttribute("className", "css-name");
		newCell.innerHTML = "<INPUT TYPE=\"TEXT\" ID=\"ORG"+intLine+"\" CLASS=\"COL3\" NAME=\"ORG\" VALUE=\""+org+"\">"				

		newCell = newRow.insertCell(12)
		newCell.id = newCell.uniqueID
		newCell.setAttribute("className", "css-name");
		newCell.innerHTML = "<SELECT ID=\"CHEESE"+intLine+"\" NAME=\"CHEESE\" CLASS=\"list\"><OPTION VALUE=\"C\">C</OPTION><OPTION VALUE=\"CS\">CS</OPTION></SELECT>"				

		newCell = newRow.insertCell(13)
		newCell.id = newCell.uniqueID
		newCell.setAttribute("className", "css-name");
		newCell.innerHTML = "<SELECT ID=\"FUAI"+intLine+"\" NAME=\"FUAI\" CLASS=\"list\"><OPTION VALUE=\" \"></OPTION><OPTION VALUE=\"F\">F</OPTION></SELECT>"				

		document.getElementById('CHEESE'+intLine+'').value = cheese;
		document.getElementById('FUAI'+intLine+'').value = fuai;
		document.getElementById('SHADE'+intLine+'').value = shade;
		document.getElementById('WP'+intLine+'').value = wp;
		document.getElementById('REC'+intLine+'').value = rec;
		document.form1.hdnMaxLine.value = intLine;
		document.form1.MaxLine.value = maxLine;

	}

function addsub(n){
		var intLine = parseInt(document.form1.hdnMaxLine.value);
		var col = document.getElementById('COL_NO'+n+'').value
		var colsub = document.getElementById('COL_SUB'+n+'').value
		var lot = document.getElementById('LOT_NO'+n+'').value
		var count = document.getElementById('COUNT'+n+'').value
		var lbs = document.getElementById('LBS'+n+'').value
		var pbls = document.getElementById('PBLS'+n+'').value
		var shade = document.getElementById('SHADE'+n+'').value
		var wp = document.getElementById('WP'+n+'').value
		var rec = document.getElementById('REC'+n+'').value
		var org = document.getElementById('ORG'+n+'').value
		var cheese = document.getElementById('CHEESE'+n+'').value
		var fuai = document.getElementById('FUAI'+n+'').value

				
		document.getElementById('COL_SUB'+n+'').value = 1;
		document.getElementById('COL_SUB'+n+'').readOnly = true;
		for(i=2;i<=colsub;i++){
		intLine++;
		var theTable = document.getElementById("maininput");
		var newRow = theTable.insertRow(theTable.rows.length)
		newRow.id = newRow.uniqueID
				
		var item1 = 1
		var newCell
		
		newCell = newRow.insertCell(0)
		newCell.id = newCell.uniqueID
		newCell.setAttribute("className", "css-name");
		newCell.innerHTML = ""+intLine+""

		newCell = newRow.insertCell(1)
		newCell.id = newCell.uniqueID
		newCell.setAttribute("className", "css-name");
		newCell.innerHTML = "<INPUT TYPE=\"TEXT\" ID=\"COL_NO"+intLine+"\" CLASS=\"COL\" NAME=\"COL_NO\" VALUE=\""+col+"\">"
		
		newCell = newRow.insertCell(2)
		newCell.id = newCell.uniqueID
		newCell.setAttribute("className", "css-name");
		newCell.innerHTML = "&nbsp;-"


		newCell = newRow.insertCell(3)
		newCell.id = newCell.uniqueID
		newCell.setAttribute("className", "css-name");
		newCell.innerHTML = "<INPUT TYPE=\"TEXT\" ID=\"COL_SUB"+intLine+"\" CLASS=\"COL2\" NAME=\"COL_SUB\" VALUE=\""+i+"\" readonly>"

		newCell = newRow.insertCell(4)
		newCell.id = newCell.uniqueID
		newCell.setAttribute("className", "css-name");
		newCell.innerHTML = "<INPUT TYPE=\"TEXT\" ID=\"LOT_NO"+intLine+"\" CLASS=\"COL3\" NAME=\"LOT_NO\" VALUE=\""+lot+"\">"		
		
		newCell = newRow.insertCell(5)
		newCell.id = newCell.uniqueID
		newCell.setAttribute("className", "css-name");
		newCell.innerHTML = "<INPUT TYPE=\"TEXT\" ID=\"COUNT"+intLine+"\" CLASS=\"COL3\" NAME=\"COUNT\" VALUE=\""+count+"\">"				
		
		newCell = newRow.insertCell(6)
		newCell.id = newCell.uniqueID
		newCell.setAttribute("className", "css-name");
		newCell.innerHTML = "<INPUT TYPE=\"TEXT\" ID=\"PBLS"+intLine+"\" CLASS=\"COL3\" NAME=\"PBLS\" VALUE=\""+pbls+"\">"			
	
		newCell = newRow.insertCell(7)
		newCell.id = newCell.uniqueID
		newCell.setAttribute("className", "css-name");
		newCell.innerHTML = "<INPUT TYPE=\"TEXT\" ID=\"LBS"+intLine+"\" CLASS=\"COL3\" NAME=\"LBS\" VALUE=\""+lbs+"\">"
		
		newCell = newRow.insertCell(8)
		newCell.id = newCell.uniqueID
		newCell.setAttribute("className", "css-name");
		newCell.innerHTML = "<SELECT ID=\"SHADE"+intLine+"\" NAME='SHADE' CLASS=\"list\"><OPTION value='P' >P</OPTION><OPTION value='M' >M</OPTION><OPTION value='D' >D</OPTION></SELECT>"
	
		newCell = newRow.insertCell(9)
		newCell.id = newCell.uniqueID
		newCell.setAttribute("className", "css-name");
		newCell.innerHTML = "<SELECT  ID=\"WP"+intLine+"\" NAME='WP' CLASS=\"list\"><OPTION VALUE=\"W\">W</OPTION><OPTION VALUE=\"P\">P</OPTION></SELECT>"
		
		newCell = newRow.insertCell(10)
		newCell.id = newCell.uniqueID
		newCell.setAttribute("className", "css-name");
		newCell.innerHTML = "<SELECT ID=\"REC"+intLine+"\" NAME='REC' CLASS=\"list\"><OPTION>BB</OPTION><OPTION>SBB</OPTION><OPTION>BC</OPTION><OPTION>SBC</OPTION><OPTION>SS</OPTION></SELECT>"

		newCell = newRow.insertCell(11)
		newCell.id = newCell.uniqueID
		newCell.setAttribute("className", "css-name");
		newCell.innerHTML = "<INPUT TYPE=\"TEXT\" ID=\"ORG"+intLine+"\" CLASS=\"COL3\" NAME=\"ORG\" VALUE=\""+org+"\">"				

		newCell = newRow.insertCell(12)
		newCell.id = newCell.uniqueID
		newCell.setAttribute("className", "css-name");
		newCell.innerHTML = "<SELECT ID=\"CHEESE"+intLine+"\" NAME=\"CHEESE\" CLASS=\"list\"><OPTION VALUE=\"C\">C</OPTION><OPTION VALUE=\"CS\">CS</OPTION></SELECT>"				

		newCell = newRow.insertCell(13)
		newCell.id = newCell.uniqueID
		newCell.setAttribute("className", "css-name");
		newCell.innerHTML = "<SELECT ID=\"FUAI"+intLine+"\" NAME=\"FUAI\" CLASS=\"list\"><OPTION VALUE=\" \"></OPTION><OPTION VALUE=\"F\">F</OPTION></SELECT>"					

		document.getElementById('CHEESE'+intLine+'').value = cheese;
		document.getElementById('FUAI'+intLine+'').value = fuai;
		document.getElementById('SHADE'+intLine+'').value = shade;
		document.getElementById('WP'+intLine+'').value = wp;
		document.getElementById('REC'+intLine+'').value = rec;
		document.form1.hdnMaxLine.value = intLine;

		}
	}

function DateTime(){
	var localTime = new Date(); 
	var year= localTime.getFullYear(); 
	var month= localTime.getMonth(); 
	var date = localTime.getDate();
	var mounth = new Array("01","02","03","04","05","06","07","08","09","10","11","12")
	document.form1.dmy.value = mounth[month]+"/"+date+"/"+year; 
}

